{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->

                <!--操作框开始-->
                <div class="col-sm-12">
                    <div class="input-group" >
                        <button class="btn btn-primary" type="button" onclick="wk.layer_show('添加订单', '{:url('orderAdd')}?type=1')">
                            <i class="fa fa-plus"></i> 添加品牌门店订单
                        </button>
                        &nbsp;&nbsp;
                        <button class="btn btn-primary" type="button" onclick="wk.layer_show('添加设计师订单', '{:url('orderAdd')}?type=2')">
                            <i class="fa fa-plus"></i> 添加设计师订单
                        </button>
                    </div>
                </div>
                <!--操作框结束-->
            </div>
            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>
                    <script type="text/html" id="staBar">
                        <input type="checkbox" value="{{d.info_id}}"  lay-skin="switch"  lay-text="启用|禁用" lay-filter="OnOff" {{ d.info_status == 1 ? 'checked' : '' }}  >
                    </script>
                    <script type="text/html" id="staBar2">
                        <input type="checkbox" value="{{d.info_id}}"  lay-skin="switch"  lay-text="是|否" lay-filter="OnOff2" {{ d.info_top == 2 ? 'checked' : '' }}  >
                    </script>
                    <!--图片显示模板-->
                    <!--<script type="text/html" id="imgTpl">-->
                        <!--<img src="{{d.pp_thumb}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"/>-->
                    <!--</script>-->
                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('编辑/详情', '{:url('orderEdit')}?info_id={{d.info_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑/详情">编辑/详情</a>
                        <a href="javascript:;" onclick="wk.confirm('{{d.info_id}}','{:url('orderDel')}','确定删除吗?')" class="btn btn-danger btn-xs m-r-xs" title="删除">删除</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Cases/caseOrder")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 300]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type: 'checkbox', fixed: 'left'}
                  {type:'numbers', width: 70, title: '序号'}
                , {field: 'info_info', width: '', title: '订单情况', align: 'center'}
                , {field: 'typename', width: '', title: '订单类型', align: 'center'}
                , {field: 'user_d_name', width: '', title: '关联设计师', align: 'center'}
                , {field: 't_name', width: '100', title: '所属分类', align: 'center'}
                , {field: 'pp_name', width: '', title: '所属品牌', align: 'center'}
                , {field: 'p_name', width: '', title: '所属装饰城', align: 'center'}
                , {field: 's_name', width: '', title: '所属门店', align: 'center'}
                , {field: 'info_money', title: '订单金额', align: 'center'}
                , {field: 'info_sort', width: '110', title: '排序(可编辑)', align: 'center', edit: 'test'}
                , {field: 'info_time', width: '', title: '发布时间', align: 'center'}
                , {field: 'status',fixed: 'right', width: 100, title: '状态', align: 'center', templet: '#staBar'}
                , {field: 'info_top',fixed: 'right', width: 100, title: '是否推荐', align: 'center', templet: '#staBar2'}
                , {fixed: 'right', width:'200', title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });
        //监听状态开关操作
        form.on('switch(OnOff)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 1: num = 2;
            //用户状态
            wk.status(this.value,num, '{:url("changeStatus")}',obj);
        });
        //监听状态开关操作
        form.on('switch(OnOff2)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 2: num = 1;
            //用户状态
            wk.status(this.value,num, '{:url("changeMainStatus")}',obj);
        });
        //批量操作
        var $ = layui.$, active = {
            //批量导出订单
            excelAll:function () {
                wk.excelAll(getIds(),$('.layui-input').serialize(),"{:url('outExcel')}");
            },
            //全部导出
            excelAllNoSelect:function () {
                wk.excelAllNoSelect($('#allidsForOut').val(),$('.layui-input').serialize(),"{:url('outExcel')}");
            }
        };
        //监听单元格编辑---排序
        table.on('edit(testReload)', function(obj){
            var value = obj.value //得到修改后的值
                ,data = obj.data //得到所在行所有键值
                ,field = obj.field; //得到字段
            wk.change(data.info_id,"{:url('updateOrderSort')}",field,value);
        });
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['user_id'])
            });
            return ids;
        };
    });
</script>
</body>
</html>